package com.ms.seguridad.support;

import java.io.Serializable;
import java.util.List;

/**
 * User: gmc
 * Date: 30/04/13
 */
public class MenuInfo implements Serializable {
    private String id;
    private String name;
    private String pageUrl;
    private List<MenuInfo> menuInfoList;
    private String descripcion;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof MenuInfo)) return false;

        MenuInfo menuInfo = (MenuInfo) o;

        if (id != null ? !id.equals(menuInfo.id) : menuInfo.id != null) return false;

        return true;
    }

    @Override
    public int hashCode() {
        return id != null ? id.hashCode() : 0;
    }

    public String getPageUrl() {
        return pageUrl;
    }

    public void setPageUrl(String pageUrl) {
        this.pageUrl = pageUrl;
    }

    public String getDefaultPage() {
        if (hasChildren()) {
            return menuInfoList.get(0).getDefaultPage();
        }
        return pageUrl;
    }

    public List<MenuInfo> getMenuInfoList() {
        return menuInfoList;
    }

    public void setMenuInfoList(List<MenuInfo> menuInfoList) {
        this.menuInfoList = menuInfoList;
    }

    public boolean hasChildren() {
        return menuInfoList != null && menuInfoList.size() > 0;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public String getDescripcion() {
        return descripcion;
    }
}
